<div class="row-fluid">
<div class="span10">
<div class="row-fluid">
<header><i class="icon-bell"></i> To Do<span class="pull-right"><i class="icon-cog"></i>&nbsp;
</span></header>
<?php 
//print_r($fav_todos)?>
<table class="table table-condensed table-striped">
<?php foreach($fav_todos as $fav_todo) {?>
<tr>
	<td width="" align="center">
					<?php if($fav_todo->is_completed == 0) {?>
					 <a href="<?php echo site_url('user/to_do/complete/'.$fav_todo->id.'/'.date('d').'/'.date('m').'/'.date('y'));?>"><i class="icon-ok-circle muted"></i></a>
					 <?php echo $fav_todo->des?>
					 <?php }else {?>
					 <a href="<?php echo site_url('user/to_do/incomplete/'.$fav_todo->id);?>"><i class="icon-ok-sign text-success"></i>					 
					 </a>
					 <?php echo $fav_todo->des?>
					 <?php }?>					 
				</td>	
	<td width="3%">			
					<a href="#" onclick="rem_fav(<?php echo $fav_todo->id?>,<?php echo date('d');?>)"><i class="icon-star"></i></a> 					
				</td>
				<td width="7%">
					<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"></i>
  <b class="caret"></b>
  				</a>
					<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">						
						<?php if(!$this->ion_auth->is_admin($this->session->userdata('user_id'))){?> 
					 	<li><a href="<?php echo site_url('user/to_do/worksheet/'.$fav_todo->id);?>" class="add_worksheet"><i class="icon-plus text-error"></i> <span class="text-error"> Add To Worksheet</span> </a></li>
						<?php }?>						
						<li><a href="#" onclick="add_fav(<?php echo $fav_todo->id?>)"><i class="icon-star"></i> Add to Fav </a></li>						
						<li><a href="<?php echo site_url('user/to_do/get_todo/'.$fav_todo->id);?>" class="get_todo"><i class="icon-edit"></i> Edit ToDo </a></li>	
						<li><a href="javascript:void(0)" onclick="delete_todo(<?php echo $fav_todo->id?>)"><i class="icon-trash"></i> Delete </a></li>
					 </ul>
					</div>
				</td>
</tr>
<?php }?>
<?php foreach($todos as $todo){?>
	<tr>
		<td width="" align="center">
					<?php if($todo->is_completed == 0) {?>
					 <a href="<?php echo site_url('user/to_do/complete/'.$todo->id.'/'.date('d').'/'.date('m').'/'.date('y'));?>"><i class="icon-ok-circle muted"></i></a>
					 <?php echo $todo->des?>
					 <?php }else {?>
					 <a href="<?php echo site_url('user/to_do/incomplete/'.$todo->id);?>"><i class="icon-ok-sign text-success"></i>					 
					 </a>
					 <?php echo $todo->des?>
					 <?php }?>					 
				</td>
				<td></td>				
			<td width="7%">
					<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"></i>
  <b class="caret"></b>
  				</a>
					<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">						
						<?php if(!$this->ion_auth->is_admin($this->session->userdata('user_id'))){?> 
					 	<li><a href="<?php echo site_url('user/to_do/worksheet/'.$todo->id);?>" class="add_worksheet"><i class="icon-plus text-error"></i> <span class="text-error"> Add To Worksheet</span> </a></li>
						<?php }?>						
						<li><a href="#" onclick="add_fav(<?php echo $todo->id?>)"><i class="icon-star"></i> Add to Fav </a></li>						
						<li><a href="<?php echo site_url('user/to_do/get_todo/'.$todo->id);?>" class="get_todo"><i class="icon-edit"></i> Edit ToDo </a></li>	
						<li><a href="javascript:void(0)" onclick="delete_todo(<?php echo $todo->id?>)"><i class="icon-trash"></i> Delete </a></li>
					 </ul>
					</div>
				</td>		
	</tr>
	<?php }?>
</table>
<a href="<?php echo site_url('user/to_do/view/'.$this->session->userdata('user_id').'/'.date('m').'/'.date('y')) ?>" >All Todo</a>
</div>

<div class="row-fluid">
<div class="span6">	
	<header> <i class="icon-star text-info"></i> Fav Task</header>
<table width="100%" class="table table-condensed table-bordered table-striped">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>Priority</th>
<th>%</th>
</tr>
<?php foreach($fav_tasks as $fav_task) {?>
  <tr>
    <td>
    <a href="<?= site_url('user/tasks/task_detail').'/'.$fav_task->task_id;?>" class="text-info"><?= $fav_task->title;?></a></td>
    <td><?= $fav_task->end_date;?></td>
    <td><?= $fav_task->priority;?></td>
	<td><?= $fav_task->completed_percentage?></td>	
  </tr>  
  <?php }?>
</table>
<a href="<?= site_url('user/tasks');?>" class="pull-right">more..</a>
	
</div>
<div class="span6">	
	<header> <i class="icon-star text-error"></i> Fav Project</header>
	<table width="100%" class="table table-condensed table-bordered table-striped">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>%</th>
</tr>
		<?php foreach($fav_projects as $fav_project) {?>
		 <tr>
    <td>
    <a href="<?php echo site_url('/user/tasks/milestones_details/'.$fav_project->id) ?>" class="text-info"><?= $fav_project->name;?></a></td>
    <td><?= $fav_project->end_date;?></td>
	<td><?php echo round($this->task_model->get_percentage_by_projectid($fav_project->id)).' %';?></td>
  </tr>
		<?php }?>
	</table>	
</div>
<a href="<?= site_url('user/tasks/my_projects');?>" class="pull-right">more..</a>
</div>

<div class="row-fluid">
<div class="span6">
<header>
<i class="icon-tasks"></i> Recent Task (s) <span class="pull-right"><i class="icon-cog"></i>&nbsp; </span>
</header>
<table class="table table-bordered table-condensed">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>Priority</th>
<th>%</th>
</tr>
<?php foreach($recent_tasks as $recent_task){?>
<tr>
<td><a href="<?= site_url('user/tasks/task_detail').'/'.$recent_task->id;?>"><?= $recent_task->title?></a></td>
<td><?= $recent_task->start_date?></td>
<td><?= $recent_task->priority?></td>
<td><?= $recent_task->completed_percentage?></td>

</tr>
<?php }?>
</table>
<div class="pull-right"><a href="<?= site_url('user/tasks');?>">more..</a></div>	
	
</div>
<div class="span6">
<header>
<i class="icon-tasks"></i> Recent Projects <span class="pull-right"><i class="icon-cog"></i>&nbsp; </span>
</header>
<table class="table table-bordered table-condensed">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>%</th>
</tr>
<?php foreach($recent_project as $recent_project) {?>
		 <tr>
    <td>
    <a href="<?php echo site_url('/user/tasks/milestones_details/'.$recent_project->id) ?>" class="text-info"><?= $recent_project->name;?></a></td>
    <td><?= $recent_project->end_date;?></td>
	<td><?php echo round($this->task_model->get_percentage_by_projectid($recent_project->id)).' %';?></td>
  </tr>
		<?php }?>
</table>
<div class="pull-right"><a href="<?= site_url('user/tasks');?>">more..</a></div>	
</div>
</div>

</div>
<div class="span2">
<header><i class="icon-signal"></i> Online User Status</header>
<div class="online-status">
<strong>Active</strong>
<ul style="font-size:11px">
<?php foreach($active_user as $active_users) {?>
<li class="text-success"><?= $active_users->username?>  - <?= date("h:i - d/m",$active_users->last_login)?></li>
<?php }?>
</ul>
<strong>InActive</strong>
<ul style="font-size:11px">
<?php foreach($inactive_user as $inactive_users) {?>
<li class="muted"><?= $inactive_users->username?>  - <?= date("h:i - d/m",$inactive_users->last_login)?></li>
<?php }?>
</ul>
</div>
</div>
</div>

<script type="text/javascript">
<!--
	function delete_todo(Id){									
		$.post('<?= site_url("user/to_do/delete");?>',{id:Id}, function(replies) {			
			location.reload();  		
	});
	}
	
	
	
$('.add_worksheet').click(function(event) {	
  event.preventDefault();
  $.get(this.href, function(html) {
  $(html).appendTo('body').modal(); 
  });
});
	
$('.get_todo').click(function(event) {	
  event.preventDefault();
  $.get(this.href, function(html) {
  $(html).appendTo('body').modal(); 
  });
});	

function add_fav(Id){	
	$.post('<?= site_url("user/to_do/add_fav");?>',{id:Id}, function(replies) {			
			location.reload();  		
	});
}

function rem_fav(Id,date_id){
	$.post('<?= site_url("user/to_do/rem_fav/date(m)/date(y);?>',{id:Id,dateId:date_id}, function(replies) {			
			location.reload();  		
	});
}

//-->
</script>